<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        header('Access-Control-Allow-Origin:*');
        $adminInfo = D("UserInfo")->getAdminInfo();
        return show(1,"列表数据",$adminInfo);
    }
    public function checkLogin(){
        header('Access-Control-Allow-Origin:*');
        $username = I("post.username",null);
        $password= I("post.password",null);
        if(is_null($username)){
            return show(0,"没有用户名");
        }
        if(is_null($password)){
            return show(0,"没有登录密码");
        }
        $result = D("UserLogin")->getLogin($username);
        if(!empty($result) && ($result['user_password'] == $password) ){
            return show(1,"登录成功");
        }else{
            return show(0,"登录失败");
        }
    }
    public function getQuestionToAdmin(){
        header('Access-Control-Allow-Origin:*');
        $resToAdmin = D("UserInfo")->getQuestion();
        if($resToAdmin){
            return show(1,"列表数据",$resToAdmin);
        }else{
            return show(0,"数据获取失败");
        }
    }
    public function getDetailByID(){
        header('Access-Control-Allow-Origin:*');
        $id = I("get.id",null);
        if(is_null($id)){
            return show(0,"没有id");
        }
       $result = D("UserInfo")->getIdForUserInfo($id);
       if($result){
           return show(1,"列表数据",$result);
       }else{
           return show(0,"数据获取失败");
       }
    }
    public function checkStatus(){
        header('Access-Control-Allow-Origin:*');
        $infoId = I("post.id",null);
        $checkId = I("post.checkId",null);
        if(is_null($infoId)){
            return show(0,"没有id");
        }
        if(is_null($checkId)){
            return show(0,"没有审核类型");
        }
        D("UserInfo")->checkUserPass($infoId,$checkId);
    }
}